

#pragma once

#include <memory>
#include <string>
#include <list>


#if 0

section
    |--- text
    |--- text
    |--- section
    |      |--- text
    |      |--- text
    |      |--- section
    |--- text
    |--- text
    |--- section
    |      |--- text
    |      |--- text
    |      |--- section
    |             |--- text
    |             |--- text
    |             |--- text
    |--- text
    |--- text

#endif

namespace tools{

    struct Section;
    struct Record;

    struct LogConfig
    {
        typedef ::std::string 
            Str;
        typedef ::std::list<Str>
            ListStr;
        typedef ::std::list<Record>
            Records;
        typedef ::std::list<Section>
            Sections;
        typedef ::std::shared_ptr<Section>
            PSection;
    };

    struct Record: LogConfig
    {
        Record(const Str& line)
            :mLine(line)
        {}
        Record(const PSection& section)
            :mSection(section)
        {}

        ListStr     mTags;
        Str         mLine;
        PSection    mSection;
    };

    struct Section:LogConfig
    {
        Section()
            : mName(), mParent(nullptr)
        {}

        Section(const Str& n)
            : mName(n), mParent(nullptr)
        {}
        Section(const Str& n, Section& p)
            : mName(n), mParent(&p)
        {}

        void AddLine(const Str& line) { mContent.emplace_back(line); }
        
        Section* AddSection(const Str& name)
        {
            PSection s = ::std::make_shared<Section>(name, *this);
            mContent.emplace_back(s);  
            return mContent.back().mSection.get();
        }

        Str         mName;
        Section*    mParent;
        Records     mContent;
    };

    struct LogCore:LogConfig
    {
       ~LogCore(){}
        LogCore();

        void AddLine(const Str& line);
        void OpenSection(const Str& name);
        void CloseSection();

        void ViewTree()const;
        void ViewContent()const;
        
        Section* mCurrent;
        Sections mSections;
    };

}//namespace tools





